package top.raoqq.sky.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

/**
 * @author 饶奇奇
 * @date 2023/8/7
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties({"token", "enabled", "accountNonExpired", "accountNonLocked", "credentialsNonExpired", "authorities"})
public class LoginUserDTO implements UserDetails {

    private String username;
    private String password;
    private String avatar;
    private String nickname;
    private String token;
    private List<String> permission;
    private LocalDateTime loginDatetime;
    private String loginIp;

    public LoginUserDTO(String username, String password, String avatar, String nickname, List<String> permission) {
        this.username = username;
        this.password = password;
        this.avatar = avatar;
        this.nickname = nickname;
        this.permission = permission;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
